final class NpcDefinition {
	public int anInt621 = -1;
	public int[] childIds;
	private boolean aBoolean623 = true;
	private int anInt624 = 932;
	private int[] anIntArray625;
	private int[] anIntArray626;
	public int anInt627 = -1;
	public long aLong628 = -1L;
	public static Client clientInstance;
	private int anInt630 = 128;
	public boolean aBoolean631 = true;
	private int anInt632 = 128;
	public int anInt633 = -1;
	private int[] anIntArray634;
	public static Cache npcCache = new Cache(30);
	public boolean aBoolean636 = true;
	public int anInt637 = -1;
	public int anInt638 = -1;
	public int anInt639 = -1;
	public int anInt641 = -1;
	public byte aByte642 = 1;
	public int anInt643 = -1;
	public boolean aBoolean644 = false;
	public int anInt645 = -1;
	public String[] aStringArray646;
	private boolean aBoolean647 = false;
	public int anInt648 = -1;
	public static int anInt649;
	private static int[] anIntArray650;
	public int anInt651 = 32;
	public String examine = "null";
	private static byte aByte653 = 6;
	public int anInt654 = -1;
	private static NpcDefinition[] npcs;
	private int[] anIntArray656;
	private static Packet aPacket_657;
	private int anInt658;
	public int anInt659 = -1;
	public byte[] aByteArray660;
	private static int anInt661;
	private boolean aBoolean662 = false;
	private int anInt663;

	private final void method368(byte i, Packet packet) {
		if (i == 6) {
		} else {
			throw new NullPointerException();
		}
		for (;;) {
			int i_0_ = packet.getUByte();
			if (i_0_ == 0) {
				break;
			}
			if (i_0_ == 1) {
				int i_1_ = packet.getUByte();
				anIntArray626 = new int[i_1_];
				for (int i_2_ = 0; i_2_ < i_1_; i_2_++) {
					anIntArray626[i_2_] = packet.getUShort();
				}
			} else if (i_0_ == 2) {
				examine = packet.getString();
			} else if (i_0_ == 3) {
				aByteArray660 = packet.getBytes();
			} else if (i_0_ == 12) {
				aByte642 = packet.getByte();
			} else if (i_0_ == 13) {
				anInt621 = packet.getUShort();
			} else if (i_0_ == 14) {
				anInt645 = packet.getUShort();
			} else if (i_0_ == 17) {
				anInt645 = packet.getUShort();
				anInt643 = packet.getUShort();
				anInt641 = packet.getUShort();
				anInt633 = packet.getUShort();
			} else if (i_0_ >= 30 && i_0_ < 40) {
				if (aStringArray646 == null) {
					aStringArray646 = new String[5];
				}
				aStringArray646[i_0_ - 30] = packet.getString();
				if (aStringArray646[i_0_ - 30].equalsIgnoreCase("hidden")) {
					aStringArray646[i_0_ - 30] = null;
				}
			} else if (i_0_ == 40) {
				int i_3_ = packet.getUByte();
				anIntArray634 = new int[i_3_];
				anIntArray656 = new int[i_3_];
				for (int i_4_ = 0; i_4_ < i_3_; i_4_++) {
					anIntArray634[i_4_] = packet.getUShort();
					anIntArray656[i_4_] = packet.getUShort();
				}
			} else if (i_0_ == 60) {
				int i_5_ = packet.getUByte();
				anIntArray625 = new int[i_5_];
				for (int i_6_ = 0; i_6_ < i_5_; i_6_++) {
					anIntArray625[i_6_] = packet.getUShort();
				}
			} else if (i_0_ == 90) {
				anInt648 = packet.getUShort();
			} else if (i_0_ == 91) {
				anInt627 = packet.getUShort();
			} else if (i_0_ == 92) {
				anInt637 = packet.getUShort();
			} else if (i_0_ == 93) {
				aBoolean636 = false;
			} else if (i_0_ == 95) {
				anInt639 = packet.getUShort();
			} else if (i_0_ == 97) {
				anInt632 = packet.getUShort();
			} else if (i_0_ == 98) {
				anInt630 = packet.getUShort();
			} else if (i_0_ == 99) {
				aBoolean644 = true;
			} else if (i_0_ == 100) {
				anInt663 = packet.getByte();
			} else if (i_0_ == 101) {
				anInt658 = packet.getByte() * 5;
			} else if (i_0_ == 102) {
				anInt638 = packet.getUShort();
			} else if (i_0_ == 103) {
				anInt651 = packet.getUShort();
			} else if (i_0_ == 106) {
				anInt654 = packet.getUShort();
				if (anInt654 == 65535) {
					anInt654 = -1;
				}
				anInt659 = packet.getUShort();
				if (anInt659 == 65535) {
					anInt659 = -1;
				}
				int i_7_ = packet.getUByte();
				childIds = new int[i_7_ + 1];
				for (int i_8_ = 0; i_8_ <= i_7_; i_8_++) {
					childIds[i_8_] = packet.getUShort();
					if (childIds[i_8_] == 65535) {
						childIds[i_8_] = -1;
					}
				}
			} else if (i_0_ == 107) {
				aBoolean631 = false;
			}
		}
	}

	public static final void method369(boolean bool) {
		NpcDefinition.npcCache = null;
		NpcDefinition.anIntArray650 = null;
		NpcDefinition.npcs = null;
		NpcDefinition.aPacket_657 = null;
		if (bool) {
			for (int i = 1; i > 0; i++) {
				/* empty */
			}
		}
	}

	public final Model method370(int i) {
		if (i <= 0) {
			for (int i_9_ = 1; i_9_ > 0; i_9_++) {
				/* empty */
			}
		}
		if (childIds != null) {
			NpcDefinition npcDefinition_10_ = method374();
			if (npcDefinition_10_ == null) {
				return null;
			}
			return npcDefinition_10_.method370(858);
		}
		if (anIntArray625 == null) {
			return null;
		}
		boolean bool = false;
		for (int i_11_ = 0; i_11_ < anIntArray625.length; i_11_++) {
			if (!Model.method589(anIntArray625[i_11_])) {
				bool = true;
			}
		}
		if (bool) {
			return null;
		}
		Model[] class50_sub1_sub4_sub4s = new Model[anIntArray625.length];
		for (int i_12_ = 0; i_12_ < anIntArray625.length; i_12_++) {
			class50_sub1_sub4_sub4s[i_12_] = Model.method588(anIntArray625[i_12_]);
		}
		Model model;
		if (class50_sub1_sub4_sub4s.length == 1) {
			model = class50_sub1_sub4_sub4s[0];
		} else {
			model = new Model(class50_sub1_sub4_sub4s.length,
				class50_sub1_sub4_sub4s, (byte) -89);
		}
		if (anIntArray634 != null) {
			for (int i_13_ = 0; i_13_ < anIntArray634.length; i_13_++) {
				model.method602(anIntArray634[i_13_], anIntArray656[i_13_]);
			}
		}
		return model;
	}

	public boolean method371(int i) {
		while (i >= 0) {
			aBoolean662 = !aBoolean662;
		}
		if (childIds == null) {
			return true;
		}
		int i_14_ = -1;
		if (anInt654 != -1) {
			VarBit varBit = VarBit.aVarBitArray824[anInt654];
			int i_15_ = varBit.anInt826;
			int i_16_ = varBit.anInt827;
			int i_17_ = varBit.anInt828;
			int i_18_ = Client.anIntArray1214[i_17_ - i_16_];
			i_14_ = NpcDefinition.clientInstance.anIntArray1039[i_15_] >> i_16_ & i_18_;
		} else if (anInt659 != -1) {
			i_14_ = NpcDefinition.clientInstance.anIntArray1039[anInt659];
		}
		if (i_14_ < 0 || i_14_ >= childIds.length || childIds[i_14_] == -1) {
			return false;
		}
		return true;
	}

	public static final void method372(Archive archive) {
		NpcDefinition.aPacket_657 = new Packet(archive.method154("npc.dat",
			null));
		Packet packet = new Packet(archive.method154(
			"npc.idx", null));
		NpcDefinition.anInt649 = packet.getUShort();
		NpcDefinition.anIntArray650 = new int[NpcDefinition.anInt649];
		int i = 2;
		for (int i_19_ = 0; i_19_ < NpcDefinition.anInt649; i_19_++) {
			NpcDefinition.anIntArray650[i_19_] = i;
			i += packet.getUShort();
		}
		NpcDefinition.npcs = new NpcDefinition[20];
		for (int i_20_ = 0; i_20_ < 20; i_20_++) {
			NpcDefinition.npcs[i_20_] = new NpcDefinition();
		}
	}

	public final Model method373(int i, int i_21_, int i_22_, int[] is) {
		if (childIds != null) {
			NpcDefinition npcDefinition_23_ = method374();
			if (npcDefinition_23_ == null) {
				return null;
			}
			return npcDefinition_23_.method373(i, i_21_, 0, is);
		}
		Model model = (Model) NpcDefinition.npcCache
			.method345(aLong628);
		if (model == null) {
			boolean bool = false;
			for (int i_24_ = 0; i_24_ < anIntArray626.length; i_24_++) {
				if (!Model.method589(anIntArray626[i_24_])) {
					bool = true;
				}
			}
			if (bool) {
				return null;
			}
			Model[] class50_sub1_sub4_sub4s = new Model[anIntArray626.length];
			for (int i_25_ = 0; i_25_ < anIntArray626.length; i_25_++) {
				class50_sub1_sub4_sub4s[i_25_] = Model
					.method588(anIntArray626[i_25_]);
			}
			if (class50_sub1_sub4_sub4s.length == 1) {
				model = class50_sub1_sub4_sub4s[0];
			} else {
				model = (new Model(
					class50_sub1_sub4_sub4s.length, class50_sub1_sub4_sub4s, (byte) -89));
			}
			if (anIntArray634 != null) {
				for (int i_26_ = 0; i_26_ < anIntArray634.length; i_26_++) {
					model.method602(anIntArray634[i_26_], anIntArray656[i_26_]);
				}
			}
			model.method595(7);
			model.preProcess(anInt663 + 64, anInt658 + 850, -30, -50, -30, true);
			NpcDefinition.npcCache.method346(model, aLong628);
		}
		Model model_27_ = Model.aModel_1643;
		if (i_22_ != 0) {
			aBoolean647 = !aBoolean647;
		}
		model_27_.method590(
			(Class21.method239(i) & Class21.method239(i_21_)),
			model, 1244);
		if (i != -1 && i_21_ != -1) {
			model_27_.method597(i_21_, 0, i, is);
		} else if (i != -1) {
			model_27_.method596(i, (byte) 6);
		}
		if (anInt632 != 128 || anInt630 != 128) {
			model_27_.method604(anInt630, anInt632, 9, anInt632);
		}
		model_27_.method592();
		model_27_.anIntArrayArray1679 = null;
		model_27_.anIntArrayArray1678 = null;
		if (aByte642 == 1) {
			model_27_.aBoolean1680 = true;
		}
		return model_27_;
	}

	public final NpcDefinition method374() {
		int i = -1;
		if (anInt654 != -1) {
			VarBit varBit = VarBit.aVarBitArray824[anInt654];
			int i_28_ = varBit.anInt826;
			int i_29_ = varBit.anInt827;
			int i_30_ = varBit.anInt828;
			int i_31_ = Client.anIntArray1214[i_30_ - i_29_];
			i = NpcDefinition.clientInstance.anIntArray1039[i_28_] >> i_29_ & i_31_;
		} else if (anInt659 != -1) {
			i = NpcDefinition.clientInstance.anIntArray1039[anInt659];
		}
		if (i < 0 || i >= childIds.length || childIds[i] == -1) {
			return null;
		}
		return NpcDefinition.method375(childIds[i]);
	}

	public static final NpcDefinition method375(int i) {
		for (int i_32_ = 0; i_32_ < 20; i_32_++) {
			if (NpcDefinition.npcs[i_32_].aLong628 == i) {
				return NpcDefinition.npcs[i_32_];
			}
		}
		NpcDefinition.anInt661 = (NpcDefinition.anInt661 + 1) % 20;
		NpcDefinition npcDefinition = NpcDefinition.npcs[NpcDefinition.anInt661] = new NpcDefinition();
		NpcDefinition.aPacket_657.offset = NpcDefinition.anIntArray650[i];
		npcDefinition.aLong628 = i;
		npcDefinition.method368(NpcDefinition.aByte653, NpcDefinition.aPacket_657);
		return npcDefinition;
	}
}
